<?php

/* $Id: config_core.php 53 2008-01-03 19:11:02Z joshuarudd $ */

error_reporting(E_STRICT | E_ALL);
date_default_timezone_set('America/Los_Angeles');
$tempObj = Array();

function setConfig($name,$value)
{
	global $tempObj;
	$tempObj[$name] = $value;
}

function createConstants()
{
	global $tempObj;
	foreach($tempObj as $key=>$value){
		if(!is_array($value) && !defined($key)){
			define($key,$value);
		}
	}
	unset($tempObj);
}

// Blackbird/SQL versions
setConfig("BLACKBIRD_VERSION","2.0_alpha");
setConfig("REQUIRED_SCHEMA_VERSION","1.0.14");

setConfig("XML_HEADER",'<?xml version="1.0" encoding="UTF-8"?>');
setConfig("SERVER",'http://'.$_SERVER['SERVER_NAME']);

setConfig("BLACKBIRD_TRIM","right");
setConfig("BLACKBIRD_DEFAULT_HOUR",19);
setConfig("BLACKBIRD_DEFAULT_MIN",30);
setConfig("BLACKBIRD_MAX_YEAR",(date('Y')+6));
setConfig("BLACKBIRD_MIN_YEAR",1990);
setConfig("BLACKBIRD_DATA_GRID_LIMIT",20);
setConfig("BLACKBIRD_TABLE_PREFIX",'blackbird_');
setConfig('BLACKBIRD_USERS_TABLE','blackbird_users');

setConfig("BLACKBIRD_FILESYSTEM",substr($_SERVER['SCRIPT_FILENAME'],0,-strlen('index.php')));
setConfig("BLACKBIRD_ROOT",substr($_SERVER['PHP_SELF'],0,-strlen('index.php')));

setConfig("INCLUDES","core/php/");
setConfig("LIB","bobolink/");
setConfig("WEB_ROOT","../");
setConfig("ASSETS","core/");
setConfig("UPLOAD_ROOT","../files/");
setConfig("UPLOAD_PATH","/files");

// Determine where the CUSTOM CONFIG files are and set the CUSTOM constant
if (file_exists(substr(substr($_SERVER['SCRIPT_FILENAME'],0,-strlen('index.php')),0,-1).'_config/config_custom.php')) {
	// Use new location - after revision 58
	define("CUSTOM","../".substr(substr($_SERVER['PHP_SELF'],0,-strlen('index.php')),1,-1)."_config/");
} elseif (file_exists('custom/config_custom.php')) {
	// Use old location - before revision 58
	define("CUSTOM","custom/");
} else {
	// Otherwise DIE!!!
	die('No config_custom.php found. You need to copy the "example_config" directory to the same level as Blackbird\'s root directory and rename it to "[Blackbird directory name]_config".');
}

require_once(CUSTOM.'config_custom.php');
createConstants();
